<?php
defined( '_JEXEC' ) or die( 'Restricted access' );

		class modACHelper
		{  
	
		/* testing */
		function getHello( $params )
		{
			return 'AC Helper Module';
		}

	
		function getData(){
		
		global $mainframe, $option;
		
		//get stuff from the URI
		$s = JRequest::getVar('view');
		$id = JRequest::getVar('id');
		$catid = JRequest::getVar('catid');
		
		if ($s =='item'){
		$mod_id = $catid;
		} elseif ($s =='category'){
		$mod_id = $id;
		}
		
		$db =& JFactory::getDBO();
			
		$query = "SELECT cc.id as catID, cc.title as catTITLE, ii.id AS id, ii.title as title, v.pdf as v_pdf  
		FROM #__categories AS cc
		LEFT JOIN #__arts_curriculum as ii ON ii.catid = cc.id
		LEFT JOIN #__arts_curriculum_vocab as v ON v.catid = cc.id
		WHERE cc.id = $mod_id AND ii.published =1 ";
		//.'ORDER BY ii.title ASC , ii.ordering';
		
		$db->setQuery( $query );
		$rows = $db->loadObjectList();
		/* loop & add to make links */
		$count = count($rows);
		  	
		  	for($i = 0; $i < $count; $i++)
		  	{
		 	$row =& $rows[$i];
		 	//two one slugs in the model one made in SQL QUERY on in a for loop in _getData()
		 	$link = JRoute::_( 'index.php?view=item&catid='.$row->catID.'&id='. $row->id);
		 	
		  	$row->link = '<a href="'. $link .'" class="mod_ac_helper_links">'. $row->title .'</a>';  
			}
		
		return $rows;
		
		}// end get data
		
		
		/* testing */
		function getURL( $params )
		{
			global $mainframe, $option;
		
		//get stuff from the URI
		$l = JRequest::getVar('view');
		$id = JRequest::getVar('id');
		$catid = JRequest::getVar('catid');
		
		if ($l =='item'){
		$l_id = $catid;
		} elseif ($l =='category'){
		$l_id = $id;
		}
		
		return $l_id;
		
		}
		
} //the end


